/**
 * 
 */
package ca.lscs.model;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.Id;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Serialized;

/**
 * @author Steve Pennington
 *
 */
public class Checklist {
	@Id
	private Long id;
	private String title;
	private String description;
	private String fileNumber;
	private String landDistrict;
	private String address;
	private Date createdDate;
	private Key<AppUser> creator;
	private Key<AppUser> asignee;
	private boolean submitted;
	@Serialized
	private Map<Key<ChecklistItem>, ChecklistState> itemStates;
	
	//Required by objectify
	public Checklist() {
		itemStates = new HashMap<Key<ChecklistItem>, ChecklistState>();
	};
	
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	public String getTitle() {
		return title;
	}
	
	public void setTitle(String title) {
		this.title = title;
	}
	
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	public String getFileNumber() {
		return fileNumber;
	}
	
	public void setFileNumber(String fileNumber) {
		this.fileNumber = fileNumber;
	}
	
	public String getLandDistrict() {
		return landDistrict;
	}
	
	public void setLandDistrict(String landDistrict) {
		this.landDistrict = landDistrict;
	}
	
	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}
	
	public Date getCreatedDate() {
		return createdDate;
	}
	
	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public void setCreator(AppUser creator) {
		this.creator = new Key<AppUser>(AppUser.class, creator.getId());
	}
	
	public void setCreator(Key<AppUser> creator) {
		this.creator = creator;
	}

	public Key<AppUser> getCreator() {
		return creator;
	}

	public void setAsignee(AppUser asignee) {
		this.asignee = new Key<AppUser>(AppUser.class, asignee.getId());
	}
	
	public void setAsignee(Key<AppUser> asignee) {
		this.asignee = asignee;
	}

	public Key<AppUser> getAsignee() {
		return asignee;
	}

	public void setSubmitted(boolean submitted) {
		this.submitted = submitted;
	}

	public boolean isSubmitted() {
		return submitted;
	}

	public void setItemStates(Map<Key<ChecklistItem>, ChecklistState> itemStates) {
		this.itemStates = itemStates;
	}

	public Map<Key<ChecklistItem>, ChecklistState> getItemStates() {
		return itemStates;
	}
	
	public ChecklistState getItemState(ChecklistItem item) {
		return itemStates.get(new Key<ChecklistItem>(ChecklistItem.class, item.getId()));
	}
	
	public void setItemState(Key<ChecklistItem> item, ChecklistState state) {
		itemStates.put(item, state);
	}
	
}
